Golang flag.Uint() function example
package flag
Uint defines a uint flag with specified name(1st parameter), default value(2nd parameter), and usage string(3rd parameter). The return value is the address of a uint variable that stores the value of the flag.
Golang flag.Uint() function usage example
package main
import (
"flag"
"fmt"
"strconv"
)
func main() {
port := flag.Uint("port", 8080, "Port to listen. Default is 8080")
flag.Parse()
fmt.Println(flag.Lookup("port")) // print the Flag struct
fmt.Printf("Port number is %s\n ", strconv.Itoa(int(*port)))
}
Output :
&{port Port to listen. Default is 8080 8080 8080}
Port number is 8080
Reference :
Advertisement
Something interesting
Tutorials
+51.1k Golang : Disable security check for HTTPS(SSL) with bad or expired certificate
+8.8k Golang : Accept any number of function arguments with three dots(...)
+9.7k Random number generation with crypto/rand in Go
+13.7k Golang : Check if an integer is negative or positive
+9.4k Facebook : Getting the friends list with PHP return JSON format
+29.5k Golang : Saving(serializing) and reading file with GOB
+16.5k Golang : Execute terminal command to remote machine example
+18.8k Golang : Delete duplicate items from a slice/array
+34.1k Golang : Create x509 certificate, private and public keys
+12.1k Golang : Sort and reverse sort a slice of runes
+7k Web : How to see your website from different countries?
+15.6k Golang : Convert date format and separator yyyy-mm-dd to dd-mm-yyyy